/* eslint-disable no-dupe-keys */
const path = require('path');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');

function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  runtimeCompiler: true, //包含编译器的内部版本
  //开发模式反向代理配置，生产模式请使用Nginx部署并配置反向代理
  devServer: {
    disableHostCheck: true,
    proxy: {
      '/api': {
        //本地服务接口地址
        target: 'https://eoatestdev.sscc.com/otc',
        ws: true,
        pathRewrite: {
          '^/api': '/'
        }
      }
    }
  },
  outputDir: "rise",
  /**
   * node_modules里的依赖默认是不会编译的,
   * 会导致es6语法在ie中的语法报错,
   * 所以需要在vue.config.js中使用transpileDependencies属性配置
   * node_modules中指定哪些文件夹或文件需要编译.
   */
  transpileDependencies: [],
  productionSourceMap: false, //是否生成.map
  configureWebpack: {
    output: {
      libraryExport: 'default' //打包类库的发布格式
    }
  },
  chainWebpack: (config) => { //webpack配置设置
    config.resolve.alias //设置别名在项目中可减少引用路径长度
      .set('@packages', resolve('packages'))
      .set('@assets', resolve('packages/assets'))
      .set('@components', resolve('packages/components'))
      .set('@utils', resolve('packages/utils'))
      .set('@mixins', resolve('packages/mixins'))
  },
  devServer: {
    open: true,
    disableHostCheck: true,
    port: 1888,
    proxy: {
      '/api': {
        //本地服务接口地址
        target: 'http://100.65.240.84:9999',
        ws: true,
        pathRewrite: {
          '^/api': '/',
        }
      },
    }
  },
  css: {
    extract: true //是否提取css文件
  },
  configureWebpack: { //webpack配置，在vue.config中专用
    plugins: [
      new MonacoWebpackPlugin()
    ]
  },
}